using UnityEngine;

public class CharacterRotation : MonoBehaviour
{
	private Vector3 targetPosition = Vector3.zero;

	public bool lookingRight;

	public float rotationForce;

	[SerializeField]
	private Transform aimPosition;

	[SerializeField]
	private Rigidbody hip;

	private void Update()
	{
		if (lookingRight)
		{
			aimPosition.localPosition = new Vector3(0f, 0f, -0.7f);
			targetPosition = hip.position + Vector3.forward * 10f;
		}
		else
		{
			aimPosition.localPosition = new Vector3(0f, 0f, 0.7f);
			targetPosition = hip.position - Vector3.forward * 10f;
		}
		Vector3 vector = hip.transform.InverseTransformPoint(targetPosition);
		float x = vector.x;
		hip.AddTorque(Vector3.up * Time.deltaTime * rotationForce * (0f - x), ForceMode.Acceleration);
	}
}
